package com.qut.graduate.busrtquery.greendao.controller;

import android.content.Context;
import com.qut.graduate.busrtquery.BRTQConstant;
import com.qut.graduate.busrtquery.greendao.dao.DaoMaster;
import com.qut.graduate.busrtquery.greendao.dao.DaoSession;

import org.greenrobot.greendao.database.Database;

/**
 * @Author WLL
 * @Time: 2019/3/27 9:06
 */
public class GreenDaoController {

    private DaoMaster daoMaster;
    private DaoSession daoSession;

    public GreenDaoController(Context context) {
//        GreenDaoContext greenDaoContext = new GreenDaoContext(context);
        BRTQSQLiteOpenHelper helper = new BRTQSQLiteOpenHelper(context, BRTQConstant.DB_NAME, null);
        Database db = helper.getWritableDb();
        daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }

    public DaoMaster getDaoMaster() {
        return daoMaster;
    }

}